import vue from '@vitejs/plugin-vue';
import {
	fileURLToPath,
	URL
} from 'node:url';
import AutoImport from 'unplugin-auto-import/vite';
import {
	ElementPlusResolver
} from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import {
	defineConfig
} from 'vite';

export default defineConfig({
	base: './', // 相当于vue.config.js中的publicPath
	build: {
		outDir: 'dist', // 打包输出目录
		assetsDir: 'static' // 静态资源存放目录
	},
	plugins: [
		vue(),
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url))
		}
	},
	// css: {
	//   preprocessorOptions: {
	//     scss: {
	//       additionalData: '@import "@/assets/style/mixin.scss";'
	//     }
	//   }
	// },
	server: {
		port: 5173,
		proxy: {
			'/backend': {
				target: 'http://1.92.130.32:8888',
				// target: 'http://localhost:8888',
				changeOrigin: true,
				rewrite: path => path.replace(/^\/backend/, '')
			}
		}
	}
});